/**********************************************************
 *
 *  Copyright (c) 2003  SeikoEpson Inc
 *  All Rights Reserved
 *
 *  File name : f_log10.c
 *  Function  :
 *        f_log10 returns Logarithm value whose base number is 10.
 *        This file is copied from math.lib of 
 *                  CC33 tool(CC33v40.exe + CCPA45.exe, 
 *                  math of ansilib33v25 )
 *  original file's Revision  :
 *      2000/02/10    first release                 M.Igarashi
 *  Revision  :
 *      2003/04/10    IrumaSoft M.Takeishi   1.st design
 *
 **********************************************************/
#include <f_math.h>
#include <f_smcvals.h>

// ALGORITHM
// 1. calculate natural logarithm
//      log10( x ) = log( x ) / log( 10 )
//

//  the architecture of single floating point
//
//   0 1          23 22            32bit
//   -----------------------------------
//  | |   exponent  |  fraction         |
//   -----------------------------------
//  |               |                   |
//  |      8bits          23 bits       |
//  |            lower word             |
//
//         bit   31         sign bit         (  1 bit  )
//             23 - 30      exponent part    (  8 bits )
//              0 - 22      fraction part    ( 23 bits )
//
//
 
float f_log10(float sfX){

	FLT_LNG   sfRet;

	sfRet._F = f_log( sfX );

	if ( ( sfRet.st._LL | 0x80000000)  == f_N_INF._F || sfRet.st._LL == f_NAN.st._LL ){		// error check
		
		return sfRet._F;
	}else{
		//sfRet = sfRet / F_LD;
		sfRet._F = sfRet._F * F_LD_REVERSE;		// log (x)/ log(10)
		return sfRet._F;
	}
}
